package com.lovol.gis.demo.common.exception;

import com.lovol.gis.demo.common.ResultEnum;

public abstract class AbstractException extends RuntimeException {
    protected final int code;
    protected final String msg;

    public int getCode() {
        return this.code;
    }

    public String getMsg() {
        return this.msg;
    }

    protected AbstractException(ResultEnum restEnum, Exception e) {
        super(restEnum.getMsg(), e);
        this.code = restEnum.getCode();
        this.msg = restEnum.getMsg();
    }

    protected AbstractException(ResultEnum restEnum, Throwable cause) {
        super(restEnum.getMsg(), cause);
        this.code = restEnum.getCode();
        this.msg = restEnum.getMsg();
    }

    protected AbstractException(ResultEnum restEnum) {
        super(restEnum.getMsg());
        this.code = restEnum.getCode();
        this.msg = restEnum.getMsg();
    }

    protected AbstractException(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    protected AbstractException(String msg) {
        super(msg);
        this.code = 0;
        this.msg = "";
    }

    protected AbstractException(String msg, Exception e) {
        super(msg, e);
        this.code = 0;
        this.msg = "";
    }

    protected AbstractException(String msg, Throwable cause) {
        super(msg, cause);
        this.code = 0;
        this.msg = "";
    }
}
